<?php
	//Libraries
	require('libraries/wideimage/WideImage.php');
	session_start();
	
	
	$image = WideImage::loadFromFile($_SESSION['images'][$_GET['image']]);
	
	if ($_GET['filtre'] == 'negate'){
		$image->applyFilter(IMG_FILTER_NEGATE)->output('jpg', 75);
	}else if ($_GET['filtre'] == 'contour'){
		$sobelPasseHaut = array();
		$sobelPasseHaut[0][0] = 1;
		$sobelPasseHaut[0][1] = 0;
		$sobelPasseHaut[0][2] = -1;
		$sobelPasseHaut[1][0] = 2;
		$sobelPasseHaut[1][1] = 0;
		$sobelPasseHaut[1][2] = -2;
		$sobelPasseHaut[2][0] = 1;
		$sobelPasseHaut[2][1] = 0;
		$sobelPasseHaut[2][2] = -1;
		$image->applyConvolution($sobelPasseHaut, 0,0)->output('jpg', 75);
	}else if ($_GET['filtre'] == 'gris'){
		$image->asGrayScale()->output('jpg', 75);
	}else if ($_GET['filtre'] == 'none'){
		$image->output('jpg',75);
	}
?>